//
//  MainTabBarController.swift
//  SinaWeibo
//
//  Created by rms on 15/10/6.
//  Copyright © 2015年 rms. All rights reserved.
//

import UIKit

class MainTabBarController: UITabBarController {
    @IBOutlet weak var mainTabBar: MainTabBar!

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewControllers()
        mainTabBar.composeButton.addTarget(self, action: "composeDidClick", forControlEvents: UIControlEvents.TouchUpInside)
        
    }
  
    func composeDidClick(){
    
        print(__FUNCTION__)
    }
    func addChildViewControllers() {
//        self.tabBar.tintColor = UIColor.orangeColor()
        addChildViewController("Home", "首页", "tabbar_home")
        addChildViewController("Message","消息", "tabbar_message_center")
        addChildViewController("Discover","发现", "tabbar_discover")
        addChildViewController("Profile","我", "tabbar_profile")

    }

    func addChildViewController(sbName:String,_ title:String,_ imageName:String) {
        let sb = UIStoryboard(name: sbName, bundle: nil)
        
        let nav = sb.instantiateInitialViewController() as! UINavigationController
        
//        nav.title = title
        nav.topViewController?.title = title
        nav.tabBarItem.image = UIImage(named: imageName)
        
        addChildViewController(nav)
    }
    

}
